#
# xen/arch/arm/Makefile
#

include $(BASEDIR)/Rules.mk

ifndef TARGET_MACHINE
$(error Unknown target platform)
endif

subdir-y += arch-$(TARGET_MACHINE) xen lib 

include $(BASEDIR)/Post.mk

OBJCOPYFLAGS    :=-O binary -R .note -R .comment -S

$(TARGET): $(TARGET)-bin $(TARGET)-syms
	@cp $(TARGET)-syms $@

$(TARGET)-syms: arch-$(TARGET_MACHINE)/start.o $(ALL_OBJS) xen.lds
	$(OBJCOPY) -I binary -O elf32-littlearm -B arm 24.bmp image.o
	$(OBJCOPY) -I binary -O elf32-littlearm -B arm 8x16 en.o
	#$(OBJCOPY) -I binary -O elf32-littlearm -B arm shut.wav sound.o
	#$(OBJCOPY) -I binary -O elf32-littlearm -B arm mini mini.o
	$(LD) $(LDFLAGS) -N -T xen.lds arch-$(TARGET_MACHINE)/start.o $(ALL_OBJS) en.o image.o -o $@ 
	#cp $@ $(BASEDIR)/xenelf
	#$(LD) -o $@ -b binary $(BASEDIR)/xenelf $(BASEDIR)/154945719.jpg

$(TARGET)-bin: $(TARGET)-syms
	$(OBJCOPY) $(OBJCOPYFLAGS) $< $@

asm-offsets.s: xen/asm-offsets.c $(HDRS)
	$(CC) $(CFLAGS) -S -o $@ $<

xen.lds: xen/xen.lds.S 
	$(CC) -E $(CFLAGS) -P -DXEN -D_XEN_ -D__XEN__ $(AFLAGS) \
	      -o $@ $<

clean:: FORCE
	rm -f arch/arm/*.o arch/arm/arch-$(TARGET_MACHINE)/*.o lib/*.o xen/*.o xen.lds
